//
//  HRZ_GoodsSortCell.m
//  EMarket
//
//  Created by 石头 on 2018/5/13.
//  Copyright © 2018年 好日子. All rights reserved.
//

#import "HRZ_GoodsSortCell.h"

#import "HRZGoodsClassifyBaseModel.h"
#import <UIImageView+WebCache.h>

@interface HRZ_GoodsSortCell()

/** imageView */
@property (strong, nonatomic) UIImageView *goodsImageView;
/** label */
@property (strong, nonatomic) UILabel *goodsTitleLabel;

@end

@implementation HRZ_GoodsSortCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.goodsImageView];
        [self addSubview:self.goodsTitleLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self);
        make.width.mas_equalTo(self).multipliedBy(0.6);
        make.height.mas_equalTo(self.width * 0.6);
    }];
    
    [self.goodsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.goodsImageView.mas_bottom).mas_offset(3);
    }];
}

#pragma mark - ----  Getter/Setter  ----
- (void)setModel:(HRZGoodsClassifyBaseModel *)model {
    
    _model = model;
    [_goodsImageView sd_setImageWithURL:URLString(_model.classifyImg) placeholderImage:PLACEHOLDERIMAGE];
    _goodsTitleLabel.text = _model.className;
}

- (UIImageView *)goodsImageView{
    if (!_goodsImageView) {
        _goodsImageView = [[UIImageView alloc] init];
        _goodsImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _goodsImageView;
}

- (UILabel *)goodsTitleLabel{
    if (!_goodsTitleLabel) {
        _goodsTitleLabel = [[UILabel alloc] init];
        _goodsTitleLabel.font = PFR12Font;
    }
    return _goodsTitleLabel;
}


@end
